package query

import (
	"ssdevice/common/dto"
	"strings"
)

type SysTagQuery struct {
	dto.Pagination `search:"-"`
	dto.OrderBy    `search:"-"`
	dto.UserInfo
	Id   string   `form:"id" json:"id" search:"type:exact;column:id;table:sys_tag"`
	Name string   `form:"name"  search:"type:contains;column:name;table:sys_tag"`
	IdIn []string `form:"idIn" search:"type:in;column:id;table:sys_tag"`
}

func (m *SysTagQuery) GetNeedSearch() interface{} {
	return *m
}

type DeviceTagStatsReq struct {
	dto.UserInfo `search:"-"`
	TagName      string   `form:"tagName" vd:"len($)>0"`
	DeptId       string   `form:"deptId"`
	DeptIdIn     []string `search:"-"`
}

func (m *DeviceTagStatsReq) GetNeedSearch() {
	if len(m.DeptId) == 0 {
		if m.UserId != "1" {
			m.DeptIdIn = m.DeptIdList
		}
	} else {
		m.DeptIdIn = strings.Split(strings.ReplaceAll(m.DeptId, " ", ""), ",")
	}

}
